home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / svgakt50.zip / SRC / SVGAKIT / TEST.ASM < prev    next >
Assembly Source File  |  1994-08-23  |  6KB  |  198 lines

  1. ;****************************************************************************
  2. ;*
  3. ;*                              The SuperVGA Kit
  4. ;*
  5. ;*                  Copyright (C) 1994 SciTech Software
  6. ;*                          All rights reserved.
  7. ;*
  8. ;* Filename:    $RCSfile: test.asm $
  9. ;* Version:     $Revision: 1.1 $
  10. ;*
  11. ;* Language:    80386 Assembler
  12. ;* Environment: IBM PC Real Mode and 16/32 bit Protected Mode.
  13. ;*
  14. ;* Description: Assembly language test routines for the SuperVGA Kit
  15. ;*                SVGATEST.EXE and PROFILE.EXE programs. These routines have
  16. ;*                been moved to this module as they are not part of the
  17. ;*                SuperVGA Kit proper as such.
  18. ;*
  19. ;* $Id: test.asm 1.1 1994/08/22 12:27:12 kjb release $
  20. ;*
  21. ;****************************************************************************
  22.  
  23.         IDEAL
  24.  
  25. INCLUDE "model.mac"             ; Memory model macros
  26.  
  27. header  test                    ; Set up memory model
  28.  
  29. CRTC    EQU 3D4h                ; Port of CRTC registers
  30.  
  31.         $EXTRN  _maxx,UINT
  32.         $EXTRN  _maxy,UINT
  33.         $EXTRN  _maxcolor,ULONG
  34.         $EXTRN  _maxpage,UINT
  35.         $EXTRN  _bytesperline,USHORT
  36.         $EXTRN  _pagesize,ULONG
  37.         $EXTRN  _curBank,UINT
  38.  
  39.         EXTRN    setBank:FPTR
  40.         EXTRN    setReadBank:FPTR
  41.  
  42. begcodeseg    test
  43.  
  44. ;----------------------------------------------------------------------------
  45. ; void _copyTest16(void)
  46. ;----------------------------------------------------------------------------
  47. ; Routine to copy the top half of video memory to the bottom half of
  48. ; video memory. To ensure that we a moving across a bank boundary in
  49. ; 16 color modes, we copy the data to the second video page.
  50. ;----------------------------------------------------------------------------
  51. procstart   __copyTest16
  52.  
  53.         enter_c    0
  54.         push    ds                    ; Save registers
  55.  
  56.         mov     _ax,[_maxy]
  57.         inc     ax
  58.         shr     ax,1                ; AX := (Yres+1) / 2
  59.         mul     [_bytesperline]
  60.         mov     cx,ax               ; CX := Number of bytes to move
  61.  
  62. ; Set up graphics controller
  63.  
  64.         mov     dx,3CEh             ; DX := Graphics Controller address port
  65.         mov     ax,0105h            ; AH := 1 (read mode 0, write mode 1)
  66.                                     ; AL := 5 (Mode register number)
  67.         out     dx,ax               ; Set up mode
  68.  
  69.         mov     di,[USHORT _pagesize] ; ES:DI := offset into destination buffer
  70.         mov     ax,[USHORT _pagesize+2]
  71.         add     di,cx
  72.         adc     al,0
  73.         call    setBank             ; Set the read/write bank number
  74.  
  75.         xor     si,si               ; DS:SI := offset into source buffer
  76.         xor     ax,ax
  77.         call    setReadBank         ; Set the read bank number
  78.  
  79.         mov        ax,0A000h
  80.         mov     ds,ax               ; DS:SI -> source buffer
  81.         mov     es,ax               ; ES:DI -> destination buffer
  82.         cld                         ; Moves go up in memory
  83.  
  84.     rep movsb                       ; Move all data in bank FAST!
  85.  
  86. ; Restore default graphics controller state
  87.  
  88.         mov     dx,3CEh             ; DX := Graphics Controller address port
  89.         mov     ax,0005h            ; default mode register value
  90.         out     dx,ax
  91.  
  92.         pop     ds
  93.         leave_c
  94.         ret
  95.  
  96. procend     __copyTest16
  97.  
  98. ;----------------------------------------------------------------------------
  99. ; void _copyTest256(void)
  100. ;----------------------------------------------------------------------------
  101. ; Routine to copy the top half of video memory to the bottom half of
  102. ; video memory, to test moving data across bank boundaries using separate
  103. ; read/write banks. To simplify the coding we move the first 100 scan
  104. ; lines down to start at scanline 205. This ensure allows us to move data
  105. ; from bank 0 to bank 2 in 640x??? display modes.
  106. ;----------------------------------------------------------------------------
  107. procstart   __copyTest256
  108.  
  109.         enter_c    0
  110.         push    ds                    ; Save registers
  111.  
  112.         mov     ax,100
  113.         mul     [_bytesperline]
  114.         mov     cx,ax               ; CX := Number of bytes to move
  115.         shr     cx,1                ; CX := Number of USHORTs to move
  116.  
  117.         mov     ax,205
  118.         mul     [_bytesperline]
  119.         mov     di,ax               ; DI := offset into destination bank
  120.         mov        al,dl
  121.         call    setBank             ; Set the read/write bank number
  122.  
  123.         xor     si,si               ; DS:SI := offset into source buffer
  124.         xor     al,al
  125.         call    setReadBank         ; Set the read bank number
  126.  
  127.         mov        ax,0A000h
  128.         mov     ds,ax               ; DS:SI -> source buffer
  129.         mov     es,ax               ; ES:DI -> destination buffer
  130.         cld                         ; Moves go up in memory
  131.  
  132.     rep movsw                       ; Move all data in bank FAST!
  133.  
  134.         pop     ds
  135.         leave_c
  136.         ret
  137.  
  138. procend     __copyTest256
  139.  
  140. ;----------------------------------------------------------------------------
  141. ; void bltImage(char *p,int numBanks,int lastBytes)
  142. ;----------------------------------------------------------------------------
  143. ; Blts and image from a memory bank to the display. This routine does
  144. ; a simple full screen Blt, and is intended to test the speed of performing
  145. ; such Blts in 32 bit protected mode for specific resolutions. This code
  146. ; will only work in 32 bit protected mode, as we need to work with _huge_
  147. ; memory blocks in a linear fashion (it will however work with the 320x200
  148. ; 256 color standard VGA mode in real mode).
  149. ;----------------------------------------------------------------------------
  150. procstart    _bltImage
  151.  
  152.         ARG        p:DPTR, numBanks:UINT, lastBytes:UINT
  153.  
  154.         enter_c    0
  155.         use_ds
  156.         push    es
  157.  
  158.         mov        ax,fs
  159.         mov        es,ax
  160.         xor        _di,_di                ; ES:_DI -> start of video memory
  161.         _lds    _si,[p]                ; DS:_SI -> memory block to Blt
  162.         xor        dl,dl                ; DL := first bank number
  163.         mov     dh,[BYTE numBanks]  ; DH := number of full banks to fill
  164.         or        dh,dh
  165.         jz        @@DoPartial            ; Only a single bank to handle
  166.  
  167. ; Move all of the full 64k banks first
  168.  
  169. @@OuterLoop:
  170.         mov        al,dl
  171.         call    setBank
  172.         mov     _cx,4000h           ; Need to set 4000h DWORDS per bank
  173.     rep movsd
  174.         xor        _di,_di
  175.         inc     dl
  176.         dec     dh
  177.         jnz     @@OuterLoop
  178.  
  179. ; Now fill the last partial bank
  180.  
  181. @@DoPartial:
  182.         mov        al,dl
  183.         call    setBank
  184.         mov     _cx,[lastBytes]
  185.         shr     _cx,2               ; _CX := number of DWORDs to set
  186.     rep movsd
  187.  
  188.         pop        es
  189.         unuse_ds
  190.         leave_c
  191.         ret
  192.  
  193. procend        _bltImage
  194.  
  195. endcodeseg    test
  196.  
  197.         END
  198.